<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="../common.inc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/calendar.js"></script>
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var customerName = document.getElementById("customerName");
		var industryId = document.getElementById("industryId");
		var areaId = document.getElementById("areaId");
		var customerSourceId = document.getElementById("customerSourceId");
		var saleStageId = document.getElementById("saleStageId");
		
		var startPredictCost = document.getElementById("startPredictCost");
		var endPredictCost = document.getElementById("endPredictCost");
	
		var startPredictContractDate = document.getElementById("startPredictContractDate");
		var endPredictContractDate = document.getElementById("endPredictContractDate");
		
		var startContactDate = document.getElementById("startContactDate");
		var endContactDate = document.getElementById("endContactDate");
		
		var salePersonId = document.getElementById("salePersonId");
		if(startPredictCost.value != ''){
			if(endPredictCost.value == ''){
				alert("请输入预测结束金额！");
				return false;
			}
		}
		if(endPredictCost.value != ''){
			if(startPredictCost.value == ''){
				alert("请输入预测开始金额！");
				return false;
			}
		}
		if(startPredictCost.value != '' && endPredictCost.value != ''){
			var d1 = startPredictCost.value;
			var d2 = endPredictCost.value;
			if(Number(d1) - Number(d2) > 0){
				alert("预测开始金额不能大于等于预测结束金额，请重新输入预测开始金额！");
				return false;
			}
		}
		
		if(startPredictContractDate.value != ''){
			if(endPredictContractDate.value == ''){
				alert("请选择预测签约结束日期！");
				return false;
			}
		}
		if(endPredictContractDate.value != ''){
			if(startPredictContractDate.value == ''){
				alert("请选择预测签约开始日期！");
				return false;
			}
		}
		if(startPredictContractDate.value != '' && endPredictContractDate.value != ''){
			var d1 = (startPredictContractDate.value).replace("-","/");
			var d2 = (endPredictContractDate.value).replace("-","/");
			if(Date.parse(d1) - Date.parse(d2) > 0){
				alert("预测签约开始日期不能比预测签约结束日期早，请重新选择预测签约开始日期！");
				return false;
			}
		}
		
		if(startContactDate.value != ''){
			if(endContactDate.value == ''){
				alert("请选择回访结束日期！");
				return false;
			}
		}
		if(endContactDate.value != ''){
			if(startContactDate.value == ''){
				alert("请选择回访开始日期！");
				return false;
			}
		}
		if(startContactDate.value != '' && endContactDate.value != ''){
			var d1 = (startContactDate.value).replace("-","/");
			var d2 = (endContactDate.value).replace("-","/");
			if(Date.parse(d1) - Date.parse(d2) > 0){
				alert("回访开始日期不能比回访结束日期早，请重新选择回访开始日期！");
				return false;
			}
		}
		
		if(customerName.value == '' && industryId.value == '0' 
			&& areaId.value == '0' && customerSourceId.value == '0' 
			&& saleStageId.value == '0' && startPredictCost.value == '' 
			&& endPredictCost.value == '' && startPredictContractDate.value == '' 
			&& endPredictContractDate.value == '' && startContactDate.value == '' && endContactDate.value == '' && salePersonId == ''){
			alert("请输入查询条件！");
			return false;
		}
		return true;
	}
	
	function queryCustomer(){
		if(checkForm()){
			var customerName = document.getElementById("customerName").value;
			var industryId = document.getElementById("industryId").value;
			var areaId = document.getElementById("areaId").value;
			var customerSourceId = document.getElementById("customerSourceId").value;
			var saleStageId = document.getElementById("saleStageId").value;
			var startPredictCost = document.getElementById("startPredictCost").value;
			var endPredictCost = document.getElementById("endPredictCost").value;
			var startPredictContractDate = document.getElementById("startPredictContractDate").value;
			var endPredictContractDate = document.getElementById("endPredictContractDate").value;
			var startContactDate = document.getElementById("startContactDate").value;
			var endContactDate = document.getElementById("endContactDate").value;
			var salePersonId = document.getElementById("salePersonId").value;
			var values = "";
			values = customerName + "," + industryId + "," + areaId + "," + customerSourceId + ",";
			values += saleStageId + "," + startPredictCost + "," + endPredictCost + ",";
			values += startPredictContractDate + "," + endPredictContractDate + "," + startContactDate + "," + endContactDate + "," +salePersonId;
			
			window.returnValue = values;
			self.close();
		}
	}
	
-->
</script>
</head>
<body><br>
	<div class="tools">
		<input class="btn1" type="button" value="确 定" onclick="queryCustomer()"/>&nbsp;&nbsp;
		<input class="btn1" type="button" value="取 消" onclick="window.close();"/>&nbsp;&nbsp;
	</div>
	
<table class="table1">
	<tr>
		<td>
			<table class="table_input" cellpadding="0" cellspacing="0" style="margin: 0 0 0 50px;">
				<tr>
					<td><!-- 客户名称 -->
						<c:choose>
							<c:when test="${language == 2}">${records['12'].currentRecordEn}：</c:when>
							<c:otherwise>${records['12'].currentRecord}：</c:otherwise>
						</c:choose>
					</td>
					<td><input id="customerName" name="customerName" class="input_long" type="text"/></td>
				</tr>
				<tr>
					<td width="20%"><!-- 行业 -->
						<c:choose>
							<c:when test="${language == 2}">${records['110'].currentRecordEn}：</c:when>
							<c:otherwise>${records['110'].currentRecord}：</c:otherwise>
						</c:choose>
					</td>
					<td width="">
						<select id="industryId" name="industryId">
							<option value="0">----------请选择----------</option>
							<c:forEach var="range" items="${ranges['110']}">
							<option value="${range.id}">${range.rangeValue}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width=""><!-- 区域 -->
						<c:choose>
							<c:when test="${language == 2}">${records['111'].currentRecordEn}：</c:when>
							<c:otherwise>${records['111'].currentRecord}：</c:otherwise>
						</c:choose>
					</td>
					<td width="">
						<select id="areaId" name="areaId">
							<option value="0">----------请选择----------</option>
							<c:forEach var="range" items="${ranges['111']}">
							<option value="${range.id}">${range.rangeValue}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<!-- 
				<tr>
					<td width="20%">销售代表：</td>
					<td><input class="input1" type="text"/></td>
				</tr>
				 -->
				<tr>
					<td width=""><!-- 客户来源 -->
						<c:choose>
							<c:when test="${language == 2}">${records['16'].currentRecordEn}：</c:when>
							<c:otherwise>${records['16'].currentRecord}：</c:otherwise>
						</c:choose>
					</td>
					<td>
						<select id="customerSourceId" name="customerSourceId">
							<option value="0">----------请选择----------</option>
							<option value="1">自拓</option>
							<option value="2">公司分派</option>
							<option value="3">市场活动</option>
							<option value="4">其他</option>
						</select>
					</td>
				</tr>
				<tr>
					<td width="20%">销售阶段：</td>
					<td>
						<select id="saleStageId" name="saleStageId">
							<option value="0">----------请选择----------</option>
							<c:forEach var="saleStage" items="${saleStages}">
							<option value="${saleStage.stageCode}">${saleStage.stageName}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				 <tr>
					<td width="20%">销售代表：</td>
					<td>
						<select id="salePersonId" name="salePersonId">
							<option value="">----------请选择----------</option>
							<c:forEach var="user" items="${users}">
								<option value="${user.id}">${user.userName}</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width="20%">预测金额：</td>
					<td>
						<input id="startPredictCost" name="startPredictCost" class="input1" type="text" size="5" onkeyup="onlyNumber(this)"/>--
						<input id="endPredictCost" name="endPredictCost" class="input1" type="text" size="5" onkeyup="onlyNumber(this)"/>元
					</td>
				</tr>
				<tr>
					<td width="20%">预测签约：</td>
					<td>
						<input id="startPredictContractDate" name="startPredictContractDate" class="input1" type="text" 
							onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>--
						<input id="endPredictContractDate" name="endPredictContractDate" class="input1" type="text" 
							onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>
					</td>
				</tr>
				<tr>
					<td width="20%">回访日期：</td>
					<td>
						<input id="startContactDate" name="startContactDate" class="input1" type="text" 
							onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>--
						<input id="endContactDate" name="endContactDate" class="input1" type="text" 
							onclick="calendar(this,'yyyy-MM-dd');" readonly="readonly"/>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>	
</body>
</html>